/**
* @project admin-go-api
* @name sysLoginInfo
* @descriptions 操作日志控制层
* @author 寒锋
* @date 2023-12-22 14:37:37
 */

package controller

import (
	"admin-go-api/api/entity"
	"admin-go-api/api/service"
	"admin-go-api/common/response"
	"admin-go-api/constants"
	"fmt"
	"github.com/gin-gonic/gin"
	"strconv"
)

// GetSysOperationLogList
// @Summary 操作日志列表接口
// @Produce json
// @Description 操作日志列表接口
// @Security ApiKeyAuth
// @Param pageNum query int false "当前页"
// @Param pageSize query int false "每页显示数量"
// @Param username query string false "用户名"
// @Param beginTime query string false "开始时间"
// @Param endTime query string false "结束时间"
// @Success 200 {object} response.Result
// @Router /api/sysOperationLog/index [get]
func GetSysOperationLogList(c *gin.Context) {
	PageNum, _ := strconv.Atoi(c.DefaultQuery("pageNum", "1"))
	PageSize, _ := strconv.Atoi(c.DefaultQuery("pageSize", "10"))
	Username := c.DefaultQuery("username", "")
	BeginTime := c.DefaultQuery("beginTime", "")
	EndTime := c.DefaultQuery("endTime", "")
	service.SysOperationLogService().GetSysOperationLogList(c, PageNum, PageSize, Username, BeginTime, EndTime)
}

// DeleteSysOperationLogById
// @Summary 删除操作日志接口
// @Produce json
// @Description 删除操作日志接口
// @Security ApiKeyAuth
// @Param data body entity.SysOperationLogIdDto true "data"
// @Success 200 {object} response.Result
// @Router /api/sysOperationLog/destroy [delete]
func DeleteSysOperationLogById(c *gin.Context) {
	var dto entity.SysOperationLogIdDto
	err := c.ShouldBind(&dto)
	if err != nil {
		response.Failed(c, int(constants.ApiCode.FAILED), fmt.Sprintf("参数错误（%s）", err.Error()))
	}
	service.SysOperationLogService().DeleteSysOperationLogById(c, dto)
}

// BatchDeleteSysOperationLog
// @Summary 批量删除操作日志接口
// @Produce json
// @Description 批量删除操作日志接口
// @Security ApiKeyAuth
// @Param data body entity.BatchDeleteSysOperationLogDto true "data"
// @Success 200 {object} response.Result
// @Router /api/sysOperationLog/batchDestroy [delete]
func BatchDeleteSysOperationLog(c *gin.Context) {
	var dto entity.BatchDeleteSysOperationLogDto
	err := c.ShouldBind(&dto)
	if err != nil {
		response.Failed(c, int(constants.ApiCode.FAILED), fmt.Sprintf("参数错误（%s）", err.Error()))
	}
	service.SysOperationLogService().BatchDeleteSysOperationLog(c, dto)
}

// CleanSysOperationLog
// @Summary 清空操作日志接口
// @Produce json
// @Description 清空操作日志接口
// @Security ApiKeyAuth
// @Success 200 {object} response.Result
// @Router /api/sysOperationLog/clean [delete]
func CleanSysOperationLog(c *gin.Context) {
	service.SysOperationLogService().CleanSysOperationLog(c)
}
